package com.sxj.corejava.code07_面向对象.封装;

/**
 * @author 石小俊
 * 2024年07月15日 14:12
 */
public class Emp {

    private String name;
    private double salary;
    private String gender;
    private int age;

    public Emp() {

    }

    public Emp(String name, double salary, String gender, int age) {
        this.name = name;
        this.salary = salary;
        this.gender = gender;
        if (age < 18) {
            this.age = 18;
        } else {
            this.age = age;
        }
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public void setAge(int age) {
        if (age < 18) {
            this.age = 18;
        } else {
            this.age = age;
        }
    }

    public String getName() {
        return name;
    }

    public double getSalary() {
        return salary;
    }

    public String getGender() {
        return gender;
    }

    public int getAge() {
        if(age < 18){
            return 18;
        }
        return age;
    }

    public void show() {
        System.out.println("姓名:" + name + ",工资:" + salary + ",性别:" + gender + ",年龄:" + age);
    }

    public void work() {
        System.out.println("每天九九六,赚赚辛苦钱");
    }

}
